package treeset;

import java.util.TreeSet;

public class Demo {
    public static void main(String[] args) {
        TreeSet<Student>list = new TreeSet<>();
        Student s1 = new Student("zhangsang",18);
        Student s2 = new Student("lisi",30);
        Student s3= new Student("wanlaowu",18);
        Student s4= new Student("jh",29);
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);

        for (Student student : list) {
            System.out.print(student+" ");
        }
        System.out.println();
    }
}
